<template>
    <div class="mui-numbox" data-numbox-min='1'>
        <button class="mui-btn mui-btn-numbox-minus" type="button">-</button>
        <input @change="countChanged" id="test" class="mui-input-numbox" type="number" value="1" ref="numbox" />
        <button class="mui-btn mui-btn-numbox-plus" type="button">+</button>
    </div>
</template>
<script>
    import mui from "../../lib/mui/js/mui"
    export default {
        data(){
            return {

            }
        },
        mounted(){
            mui(".mui-numbox").numbox();
        },
        methods: {
            countChanged(){
            //    当文本框的数据发生改变时，就将数据传给父组件
                this.$emit("getcount",parseInt(this.$refs.numbox.value));
            }
        },
        props: ['max'],
        watch: {
            "max": function(newVal,oldVal){
                //使用JS API设置 numbox
                mui(".mui-numbox").numbox().setOption('max',newVal)
            }
        }
    }
</script>
<style lang="less" scoped>

</style>